/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufpe.cin.dmo4.middleware.server.remoteobjects;

import java.lang.reflect.Method;

/**
 *
 * @author Danilo
 */
public class Teste {
    private String key;
    private String value;

    public Teste(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public Teste() {
        this("-", "-");
    }
    
    
    
    public void set(String key, String value){
        this.key = key;
        this.value = value;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return key + ": " + value;
    }
    
    public void print(){
        System.out.println(">>>" + toString());
    }
    
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("br.ufpe.cin.dmo4.middleware.server.remoteobjects.Teste");
        
        Teste obj = (Teste) cls.newInstance();
        
        Method method = cls.getDeclaredMethod("print", new Class[]{});
        method.invoke(obj, new Object[]{});
        
        
        Method method2 = cls.getDeclaredMethod("set", new Class[]{String.class, String.class});
        method2.invoke(obj, new Object[]{"ronaldo", "felomeno"});
        
        
        Method method3 = cls.getDeclaredMethod("toString", new Class[]{});
        String str = (String) method3.invoke(obj, new Object[]{});
        System.out.println(str);
        
    }
    
}
